<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">
	
	<a4j:form id="paymentOrderDetListForm">
		<a4j:outputPanel id="paymentOrderDetListMsgContainer" ajaxRendered="true">
			<h:messages globalOnly="false" errorClass="msgError" styleClass="message" infoClass="msgInfo" />
		</a4j:outputPanel>
		<a4j:outputPanel id="paymentOrderDetListGridPanel" ajaxRendered="true">	
			<rich:panel styleClass="table_add">
			<rich:dataTable
			   id="paymentOrderDetListGrid" 
               value="#{trnPaymentOrder.paymentOrderDetForLoad}" 
               var="row"
               rows="20">
					<rich:column rendered="#{not empty trnPaymentOrder.paymentOrderDetForLoad}">
						<f:facet name="header"><h:outputText value="Fecha Comprobante" /></f:facet>
						<h:outputText value="#{row.voucherDate}" />
					</rich:column>
					<rich:column rendered="#{not empty trnPaymentOrder.paymentOrderDetForLoad}">
						<f:facet name="header"><h:outputText value="Nro. Comprobante" /></f:facet>
						<h:outputText value="#{comAssist.getInvoiceNumber(row.establishment, row.expedition, row.voucher, row.instalments)}" />
					</rich:column>
					<rich:column rendered="#{not empty trnPaymentOrder.paymentOrderDetForLoad}">
						<f:facet name="header"><h:outputText value="Total Comprobante" /></f:facet>
						<h:outputText value="#{row.residuePaymentOrden}" />
					</rich:column>
					
					<rich:column 
						rendered="#{not empty trnPaymentOrder.paymentOrderDetForLoad}">
						<f:facet name="header"><h:outputText value="Total Pago" /></f:facet>
						<a4j:outputPanel id="payOrderDetListAmountPanel">
						<h:inputText 
							value="#{row.amountOfPaymentOrden}" 
							disabled="#{trnPaymentOrder.enableIfRowSelected(row.selected)}">
							<rich:ajaxValidator 
	                 			event="onblur"
	                 			onsubmit="validateTableDecimalField(
	                 				fieldObject = this, 
	                 				fieldMsgId = 'payOrderDetListAmountMsg#{row.voucher}#{row.instalments}', 
	                 				required = 'true', 
	                 				requiredMsg = 'Favor ingrese el monto a pagar',
	                 				checkForZero = 'true',
	                 				max = #{row.residuePaymentOrden},
	                 				errorClass = 'msgErrorDetRow',
	                 				errorInput = 'inputErrorDet')">
	   						</rich:ajaxValidator>	
   						</h:inputText>
   						</a4j:outputPanel>
						<div id="payOrderDetListAmountMsg#{row.voucher}#{row.instalments}"
							class="inactiveMsg"></div>
					</rich:column>
					
					<rich:column rendered="#{not empty trnPaymentOrder.paymentOrderDetForLoad}">
						<f:facet name="header"><h:outputText value="Seleccionar" /></f:facet>
						<h:selectBooleanCheckbox value="#{row.selected}">
							<a4j:support action="#{trnPaymentOrder.resetAmount(row, row.selected)}" event="onchange" reRender="payOrderDetListAmountPanel"/>
						</h:selectBooleanCheckbox>
					</rich:column>
			</rich:dataTable> 
			</rich:panel>
			<rich:datascroller align="center" for="paymentOrderDetListGrid"
					maxPages="15" page="#{trnPaymentOrder.scrollerPage}"
					renderIfSinglePage="false" />			   			
			<div style="clear: both;" />
			<s:decorate template="/layout/displayButton.xhtml" styleClass="button_form" style="margin-left:3px; margin-top:7px; width:234px;">
				<a4j:commandButton 
					id="payOrderLoadVouchersBtn" 
					action="#{trnPaymentOrder.loadGridVouchers()}"
					value="Agregar" 
					reRender="PayOrderDetGridPanel, PayOrderDetGrid" 
					disabled="#{empty trnPaymentOrder.paymentOrderDetForLoad}"
					styleClass="button"
					style="FONT-FAMILY: 'Century Schoolbook L'; position:relative; padding-bottom:4px;"
					onclick="onRequestStart();"
					oncomplete="onRequestEnd();if(#{empty facesContext.maximumSeverity})#{rich:component('paymentOrderDetListModalPanel')}.hide();"/>
			</s:decorate>
		</a4j:outputPanel>
	</a4j:form>

</ui:composition>